package com.itheima.sso.controller;

import com.itheima.model.common.dtos.ResponseResult;
import com.itheima.model.common.pojos.User;
import com.itheima.sso.service.LoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class LoginController {

    private final LoginService loginService;

    @PostMapping("/login")
    public ResponseResult login(@RequestBody User user) {

        return ResponseResult.okResult(loginService.login(user));
    }

    //校验token
    @PostMapping("/checkToken")
    public User checkToken(@RequestBody String token) {
        return loginService.checkToken(token);
    }
}
